﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using TJADRICD.DLL;
using TJADRICD.Model;

namespace TJADRICD.BLL
{
   public class ProjectInformationService
    {
       //获取项目信息
       public  ProjectInformation getProjectInFo(string pn,string spn)
       {
           return (new ProjectInformationDll()).getProjectInformation(pn,spn);
       }

       //根据获取的文件路径信息，进行项目和子项目名称的提取
       public string[] getPnAndSpn(string path)
       {
           int Pn_begin = path.LastIndexOf("\\")+1;
           int Pn_end = path.LastIndexOf("-");//项目名称结束，也是子项目名称开始
           int Spn_end = path.LastIndexOf(".");
           string pn = path.Substring(Pn_begin, Pn_end - Pn_begin);
           string spn = path.Substring(Pn_end+1,Spn_end-Pn_end);
           string[] PnAndSpn = {pn,spn};
           return PnAndSpn;
       }
       //这个方法和getPnAndSpn具有相同的功能，只是为了取值方便
       public Hashtable getPnAndSubPn(string path)
       {
           try
           {
               int Pn_begin = path.LastIndexOf("\\") + 1;
               int Pn_end = path.LastIndexOf("-");//项目名称结束，也是子项目名称开始
               int Spn_end = path.LastIndexOf(".")-1;
               string pn = path.Substring(Pn_begin, Pn_end - Pn_begin);
               string spn = path.Substring(Pn_end + 1, Spn_end - Pn_end);
               Hashtable PnAndSubPn = new Hashtable();
               PnAndSubPn.Add("pn", pn);
               PnAndSubPn.Add("spn", spn);
               return PnAndSubPn;
           }
           catch(Exception e)
           {
               Console.WriteLine("获取项目信息的方式发生了错误："+e.Message+"，建议你按正确流程进行操作!");
           }
           return null;
       }
    }
}
